//
// Created by immor on 2025/4/6.
//

#ifndef LINUX_TWO_WIRE_H
#define LINUX_TWO_WIRE_H

#define I2C_MAX_BUFFER_SIZE 256
#include <iostream>

class LinuxI2C;
using TwoWire = LinuxI2C;
class LinuxI2C {
public:
    explicit LinuxI2C(const char* device);

    ~LinuxI2C();

    void beginTransmission(uint8_t addr) const;
    size_t write(uint8_t data) ;

    uint8_t endTransmission();

    uint8_t requestFrom(uint8_t addr, uint8_t len) ;

    uint8_t read() ;

private:
    int _fd;
    uint8_t _buffer[I2C_MAX_BUFFER_SIZE]{};
    uint32_t _bufferEndIndex {0};

};




#endif // LINUX_TWO_WIRE_H
